import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { getCategory, searchTools, categoryTree } from "@/lib/public/queries"; import { parseFilters, type SP } from "@/lib/public/params"; import { Breadcrumbs } from "@/components/breadcrumbs"; import { ToolCard } from "@/components/tool-card"; import { Pagination } from "@/components/pagination"; export const revalidate = 600; export async function generateStaticParams() { try { const t = await categoryTree(); return t.flatMap((c) => [{ slug: c.slug }, ...c.children.map((x) => ({ slug: x.slug }))]); } catch { return []; } } export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise { const c = await getCategory((await params).slug); if (!c) return { title: "Not found" }; return { title: `${c.name} tools`, description: c.description, alternates: { canonical: `/categories/${c.slug}` } }; } export default async function CategoryPage({ params, searchParams }: { params: Promise<{ slug: string }>; searchParams: Promise }) { const { slug } = await params; const c = await getCategory(slug); if (!c) notFound(); const f = parseFilters(await searchParams); const res = await searchTools({ ...f, category: [slug], sort: f.sort ?? "quality" }); return (

{c.name}

{c.description}

{c.children.length > 0 &&
    {c.children.map((ch) =>
  • {ch.name} {ch.count}
  • )}
}

{res.total} tools

Filter in directory →

Tools in this category

{res.items.length ?
{res.items.map((t) => )}
:

No published tools in this category yet.

} `/categories/${slug}?page=${p}`} />
); }